fn generate_queue() -> Mutex<Queue> {
    let queue = queue_new();
    let mut queue = Mutex::new(queue);
    {
        let mut queue = queue.lock().unwrap();
        for _ in 0..1000 {
            queue_push_head(&mut queue, &VARIABLE1);
            queue_push_head(&mut queue, &VARIABLE2);
            queue_push_head(&mut queue, &VARIABLE3);
            queue_push_head(&mut queue, &VARIABLE4);
        }
    }
    queue
}
#[test]
fn test_queue_new_free() {
    let mut i: isize;
    let mut variable1: i32 = 1;
    let mut queue = queue_new();
    queue_free(queue);
    queue = queue_new();
    for i in 0..1000 {
        queue.push_head(&mut variable1);
    }
    queue_free(queue);
    alloc_test_set_limit(0);
    unsafe {
        if check_alloc_limit() {
            queue = queue_new();
            assert!(false);
        } else {
            assert!(true);
        }
    }
}
#[test]
fn test_queue_push_head() {
    let queue: *mut Queue;
    let i: i32;
    queue = queue_new();
    for j in 0..1000 {
        queue_push_tail(queue, &variable1);
        queue_push_tail(queue, &variable2);
        queue_push_tail(queue, &variable3);
        queue_push_tail(queue, &variable4);
    }
    assert!(!queue_is_empty(queue));
    assert!(queue_pop_head(queue) == &variable1);
    assert!(queue_pop_head(queue) == &variable2);
    assert!(queue_pop_head(queue) == &variable3);
    assert!(queue_pop_head(queue) == &variable4);
    assert!(queue_pop_tail(queue) == &variable4);
    assert!(queue_pop_tail(queue) == &variable3);
    assert!(queue_pop_tail(queue) == &variable2);
    assert!(queue_pop_tail(queue) == &variable1);
    queue_free(queue);
    queue = queue_new();
    alloc_test_set_limit(0);
    assert!(!queue_push_tail(queue, &variable1));
    queue_free(queue);
}
#[test]
fn test_queue_pop_tail() {
    unsafe {
        let queue = Queue::new();
        assert!(Queue::is_empty(queue));
        let variable1: *mut Variable1 = libc::malloc(mem::size_of::<Variable1>()) as *mut Variable1;
        if variable1.is_null() {
            panic!("Failed to allocate memory for Variable1");
        }
        Queue::push_head(queue, variable1);
        assert!(!Queue::is_empty(queue));
        Queue::pop_head(queue);
        assert!(Queue::is_empty(queue));
        Queue::push_tail(queue, variable1);
        assert!(!Queue::is_empty(queue));
        Queue::pop_tail(queue);
        assert!(Queue::is_empty(queue));
        libc::free(variable1 as *mut libc::c_void);
        Queue::free(queue);
    }
}
fn main() {
    run_tests();
    println!("num_assert: {}", NUM_ASSERT.load(Ordering::SeqCst));
}
